package com.aaa.controller;

import com.aaa.entity.Buy;
import com.aaa.service.impl.BuyServiceImpl;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.Date;
import java.util.List;

@CrossOrigin
@Controller
@RequestMapping("buy")
public class BuyController {
    @Resource
    BuyServiceImpl buyService;
    @RequestMapping("list")
    @ResponseBody
    public List<Buy> list(){
        return buyService.list();
    }
    @RequestMapping("update")
    @ResponseBody
    public Boolean update(Buy buy){
        return buyService.updateById(buy);
    }
    @RequestMapping("save")
    @ResponseBody
    public Boolean save(Buy buy){
        buy.setTime(new Date());
        return buyService.save(buy);
    }
}
